package com.grupoconstruobras.sigo.general.enums.security;

/**
 * Enum to list all currently implemented CRUD operations (but also
 * non-CRUD, custom operations) on a given resource, as defined in the
 * permissions model for SIJYP.
 * 
 * @author leonardo.contreras
 * @author ricardo.buitrago
 */
public enum Permiso {
  Actualizar, Consultar, Crear, Eliminar, Enviar, GenerarReporte;

  public String toString() {
    return name();
  }

  public boolean matches(String other) {

    try {

      Permiso otherPermiso = valueOf(Permiso.class, other);
      return otherPermiso.equals(this);

    } catch (IllegalArgumentException e) {
      return false;
    } catch (NullPointerException e) {
      return false;
    }
  }
}
